//
// UTransform.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------

package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CVector;

public class UTransform extends UTransformable {
  private long swigCPtr;

  public UTransform(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.UTransform_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(UTransform obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_UTransform(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public void parent(UTransform newFather) {
    nel3dJNI.UTransform_parent(swigCPtr, this, UTransform.getCPtr(newFather), newFather);
  }

  public void setClusterSystem(UInstanceGroup pIG) {
    nel3dJNI.UTransform_setClusterSystem(swigCPtr, this, UInstanceGroup.getCPtr(pIG), pIG);
  }

  public UInstanceGroup getClusterSystem() {
    long cPtr = nel3dJNI.UTransform_getClusterSystem(swigCPtr, this);
    return (cPtr == 0) ? null : new UInstanceGroup(cPtr, false);
  }

  public void hide() {
    nel3dJNI.UTransform_hide(swigCPtr, this);
  }

  public void show() {
    nel3dJNI.UTransform_show(swigCPtr, this);
  }

  public void setUserClipping(boolean enable) {
    nel3dJNI.UTransform_setUserClipping(swigCPtr, this, enable);
  }

  public boolean getUserClipping() {
    return nel3dJNI.UTransform_getUserClipping(swigCPtr, this);
  }

  public void heritVisibility() {
    nel3dJNI.UTransform_heritVisibility(swigCPtr, this);
  }

  public UTransform.TVisibility getVisibility() {
    return UTransform.TVisibility.swigToEnum(nel3dJNI.UTransform_getVisibility(swigCPtr, this));
  }

  public void freezeHRC() {
    nel3dJNI.UTransform_freezeHRC(swigCPtr, this);
  }

  public void unfreezeHRC() {
    nel3dJNI.UTransform_unfreezeHRC(swigCPtr, this);
  }

  public void setUserLightable(boolean enable) {
    nel3dJNI.UTransform_setUserLightable(swigCPtr, this, enable);
  }

  public boolean getUserLightable() {
    return nel3dJNI.UTransform_getUserLightable(swigCPtr, this);
  }

  public void setOrderingLayer(long layer) {
    nel3dJNI.UTransform_setOrderingLayer(swigCPtr, this, layer);
  }

  public long getOrderingLayer() {
    return nel3dJNI.UTransform_getOrderingLayer(swigCPtr, this);
  }

  public void setLogicInfo(ILogicInfo logicInfo) {
    nel3dJNI.UTransform_setLogicInfo(swigCPtr, this, ILogicInfo.getCPtr(logicInfo), logicInfo);
  }

  public boolean getLastWorldVisState() {
    return nel3dJNI.UTransform_getLastWorldVisState(swigCPtr, this);
  }

  public boolean getLastClippedState() {
    return nel3dJNI.UTransform_getLastClippedState(swigCPtr, this);
  }

  public void getLastParentClusters(SWIGTYPE_p_std__vectorT_NL3D__CCluster_p_t clusters) {
    nel3dJNI.UTransform_getLastParentClusters(swigCPtr, this, SWIGTYPE_p_std__vectorT_NL3D__CCluster_p_t.getCPtr(clusters));
  }

  public SWIGTYPE_p_NLMISC__CMatrix getLastWorldMatrixComputed() {
    return new SWIGTYPE_p_NLMISC__CMatrix(nel3dJNI.UTransform_getLastWorldMatrixComputed(swigCPtr, this), false);
  }

  public void setLoadBalancingGroup(String group) {
    nel3dJNI.UTransform_setLoadBalancingGroup(swigCPtr, this, group);
  }

  public String getLoadBalancingGroup() {
    return nel3dJNI.UTransform_getLoadBalancingGroup(swigCPtr, this);
  }

  public void setMeanColor(CRGBA color) {
    nel3dJNI.UTransform_setMeanColor(swigCPtr, this, CRGBA.getCPtr(color), color);
  }

  public CRGBA getMeanColor() {
    return new CRGBA(nel3dJNI.UTransform_getMeanColor(swigCPtr, this), true);
  }

  public boolean supportFastIntersect() {
    return nel3dJNI.UTransform_supportFastIntersect(swigCPtr, this);
  }

  public boolean fastIntersect(CVector p0, CVector dir, SWIGTYPE_p_float dist2D, SWIGTYPE_p_float distZ, boolean computeDist2D) {
    return nel3dJNI.UTransform_fastIntersect(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(dir), dir, SWIGTYPE_p_float.getCPtr(dist2D), SWIGTYPE_p_float.getCPtr(distZ), computeDist2D);
  }

  public void setTransparency(boolean v) {
    nel3dJNI.UTransform_setTransparency(swigCPtr, this, v);
  }

  public void setOpacity(boolean v) {
    nel3dJNI.UTransform_setOpacity(swigCPtr, this, v);
  }

  public long isOpaque() {
    return nel3dJNI.UTransform_isOpaque(swigCPtr, this);
  }

  public long isTransparent() {
    return nel3dJNI.UTransform_isTransparent(swigCPtr, this);
  }

  public void setBypassLODOpacityFlag(boolean bypass) {
    nel3dJNI.UTransform_setBypassLODOpacityFlag(swigCPtr, this, bypass);
  }

  public void setTransparencyPriority(short priority) {
    nel3dJNI.UTransform_setTransparencyPriority(swigCPtr, this, priority);
  }

  public void enableCastShadowMap(boolean state) {
    nel3dJNI.UTransform_enableCastShadowMap(swigCPtr, this, state);
  }

  public boolean canCastShadowMap() {
    return nel3dJNI.UTransform_canCastShadowMap(swigCPtr, this);
  }

  public void enableReceiveShadowMap(boolean state) {
    nel3dJNI.UTransform_enableReceiveShadowMap(swigCPtr, this, state);
  }

  public boolean canReceiveShadowMap() {
    return nel3dJNI.UTransform_canReceiveShadowMap(swigCPtr, this);
  }

  public void setShadowMapDirectionZThreshold(float zthre) {
    nel3dJNI.UTransform_setShadowMapDirectionZThreshold(swigCPtr, this, zthre);
  }

  public float getShadowMapDirectionZThreshold() {
    return nel3dJNI.UTransform_getShadowMapDirectionZThreshold(swigCPtr, this);
  }

  public void setShadowMapMaxDepth(float depth) {
    nel3dJNI.UTransform_setShadowMapMaxDepth(swigCPtr, this, depth);
  }

  public float getShadowMapMaxDepth() {
    return nel3dJNI.UTransform_getShadowMapMaxDepth(swigCPtr, this);
  }

  public void setForceClipRoot(boolean forceClipRoot) {
    nel3dJNI.UTransform_setForceClipRoot(swigCPtr, this, forceClipRoot);
  }

  public boolean getForceClipRoot() {
    return nel3dJNI.UTransform_getForceClipRoot(swigCPtr, this);
  }

  public UTransform() {
    this(nel3dJNI.new_UTransform__SWIG_0(), true);
  }

  public UTransform(CTransform object) {
    this(nel3dJNI.new_UTransform__SWIG_1(CTransform.getCPtr(object), object), true);
  }

  public void attach(CTransform object) {
    nel3dJNI.UTransform_attach(swigCPtr, this, CTransform.getCPtr(object), object);
  }

  public void detach() {
    nel3dJNI.UTransform_detach(swigCPtr, this);
  }

  public boolean empty() {
    return nel3dJNI.UTransform_empty(swigCPtr, this);
  }
  /**
   * @todo check
   */
  public ITransformable getObjectPtr() {
    long cPtr = nel3dJNI.UTransform_getObjectPtr(swigCPtr, this);
    return (cPtr == 0) ? null : new CTransform(cPtr, false);
  }

  public final static class TVisibility {
    public final static TVisibility Show = new TVisibility("Show", nel3dJNI.UTransform_Show_get());
    public final static TVisibility Hide = new TVisibility("Hide");
    public final static TVisibility Herit = new TVisibility("Herit");
    public final static TVisibility VisibilityCount = new TVisibility("VisibilityCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TVisibility swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TVisibility.class + " with value " + swigValue);
    }

    private TVisibility(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TVisibility(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TVisibility(String swigName, TVisibility swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TVisibility[] swigValues = { Show, Hide, Herit, VisibilityCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
